package com.qf.taobei.service.impl;

import com.qf.taobei.entity.Admin;
import com.qf.taobei.entity.RespBean;
import com.qf.taobei.mapper.AdminMapper;
import com.qf.taobei.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;

@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminMapper adminMapper;

    @Override
    public RespBean adminLogin(HttpSession session, String username, String password) {
        Admin admin = adminMapper.adminLogin(username,password);
        if (admin == null){
            return RespBean.respError("账号或密码错误！");
        }else {
            session.setAttribute("admin",username);
            return RespBean.respSuccess("登录成功！",username);
        }
    }
}
